import "css";
import { poem } from './poem.js'; //引入数据
import Bscroll from 'better-scroll'; //引入better-scroll
import { runInThisContext } from "vm";
import 'babel-polyfill'
import BScroll from 'better-scroll'

class Ani {
    constructor(option) {
        this.data = option.data;
        this.con = document.querySelector('.con');
        this.bscroll = new Bscroll('.wrap');
        this.init();
    }
    async init() {
        for (let i = 0; i < this.data.length; i++) {
            await this.createElement(i)
        }
    }
    createElement(i) {
        return new Promise((resolve, reject) => {
            let el = document.createElement('p');
            el.innerHTML = this.data[i];
            this.con.appendChild(el);
            this.bscroll.scrollToElement(el)
            setTimeout(() => {
                resolve(true)
            }, 1000)
        })
    }
}
new Ani({
    data: poem
})